package wen.recommend.servlet.book;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import wen.recommend.beans.Books;
import wen.recommend.dao.BookDao;

/*
访问首页的Servlet
*/

public class BookListServlet extends HttpServlet {

	BookDao bookDao =new BookDao();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);

	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		        //获取所有的推荐信息
				List<Books> recommendations = bookDao.findRecommendations();
				//把数据存储到Request域对象中
				request.setAttribute("recommendations", recommendations);
				//页面跳转到首页的JSP页面
				request.getRequestDispatcher("/WEB-INF/jsp/bookIndex.jsp")
					.forward(request, response);
			}


	}

